import convert from 'koa-convert'
import mount from 'koa-mount'
import logger from './logger'
import Koa from 'koa'
import graphqlHTTP from 'koa-graphql'

export default (config, schema) => {
    let app = new Koa();

    // graphql
    app.use(mount(config.graphql.path, convert(graphqlHTTP({
        schema: schema,
        graphiql: config.graphql.graphiql,
    }))));

    app.listen(config.listen.koa);
    logger.info(`http query server listen: ${config.listen.koa}`);
}
